package com.javase.A02;

import java.util.Random;
import java.util.Scanner;

public class A2_5剪刀石头布小游戏 {
    public static void main(String[] args) {
        Random random = new Random();
        Scanner sc = new Scanner(System.in);
        System.out.println("程序已启动");
        String[] gesture = {"石头","剪刀","布"};
        int personWin = 0;
        int computerWin = 0;
        int draw = 0;
        for (int i = 0; i < 5; i++) {
            int session = i + 1;
            System.out.println("第"+session+"局：请猜拳 剪刀 石头 布");
            String person = sc.next();
            int ranNum = random.nextInt(3);

            if(person.equals("剪刀")){
                switch (ranNum){
                    case 0:
                        System.out.println("您出的剪刀，电脑出的剪刀，平局！");
                        draw++;
                        break;
                    case 1:
                        System.out.println("您出的剪刀，电脑出的石头，您输了！");
                        computerWin++;
                        break;
                    case 2:
                        System.out.println("您出的剪刀，电脑出的布，您赢了！");
                        personWin++;
                        break;
                }
            }else if (person.equals("石头")){
                switch (ranNum){
                    case 0:
                        System.out.println("您出的石头，电脑出的剪刀，您赢了！");
                        personWin++;
                        break;
                    case 1:
                        System.out.println("您出的石头，电脑出的石头，平局！");
                        draw++;
                        break;
                    case 2:
                        System.out.println("您出的石头，电脑出的布，您输了！");
                        computerWin++;
                        break;
                }
            }else if(person.equals("布")){
                switch (ranNum){
                    case 0:
                        System.out.println("您出的布，电脑出的剪刀，您输了！");
                        computerWin++;
                        break;
                    case 1:
                        System.out.println("您出的布，电脑出的石头，您赢了了！");
                        personWin++;
                        break;
                    case 2:
                        System.out.println("您出的布，电脑出的布，平局！");
                        draw++;
                        break;
                }
            }else{
                System.out.println("未识别到您的手势");
            }
        }
        System.out.println("您赢了" + personWin + "局,平了" + draw + "局");
    }
}
